<script>
function removefeature(id) {
	if(confirm('Are you sure you want to remove this item from feature list?')) {
		window.location = '<?=base_url()?>admin/store/removefeature/' + id;
	}
}
function searchproduct() {
	var keyword = $j('#keyword').val();
	var category = $j('#category').val();
	$j.ajax({
		url: '<?=base_url()?>admin/store/searchfeature',
		type: 'POST',
		data: ({keyword:keyword,category:category}),
		dataType: "html",
		success: function(html) {
			$j('#addfeature').html(html);
		}
	})
}
</script>
    	<div class="left">
        	<h1>Store Management</h1>
            <div class="bar">

            	<div class="text">Manage Homepage</div>
            	<div class="cr"></div>
            </div>
            <div class="box">
            	<h3>Feature Products</h3>
                <div class="feature">
					<?php $n = 0; if($features) 
					foreach($features as $product) 
					{ $n++; ?>
                  <div class="box_container">
                    <div class="item">
                    <?php $hero = $this->Product_model->get_hero($product['id']); 
                        if ($hero) 
						{ ?>
                        <img src="<?=base_url()?>uploads/products/<?=md5('mbb'.$product['id'])?>/thumb3/<?=$hero['name']?>" />                
                        <?php } else { ?>
                        No image
                        <?php } ?>
                        
                    </div>
                       <div class="nav">
                            <a href="javascript:removefeature(<?=$product['id']?>)" title="Remove this item"><img src="<?=base_url()?>img/backend/icon-delete.png" /></a><?php if($n>1) { ?><a href="<?=base_url()?>admin/store/movefeature/<?=$product['id']?>/-1"><img src="<?=base_url()?>img/backend/icon-moveleft.png" /></a><?php } ?><?php if($n<count($features)) { ?><a href="<?=base_url()?>admin/store/movefeature/<?=$product['id']?>/1"><img src="<?=base_url()?>img/backend/icon-moveright.png" /></a><?php } ?>
                        </div>
                      </div>
                    <?php 
					} ?>
                    <dl></dl>
                    <?php if($this->session->flashdata('addft_true')) { ?>
                    <p class="error">Error: maximum 6 features products in the homepage</p>
                    <?php 
					} ?>                    
                </div>
                <dl></dl>
            </div>
            <hr />
            <div class="box bgw">
            	<h3>Search Product</h3>
                <dl class="one"><dt>Keyword</dt><dd><input type="text" class="textfield rounded" id="keyword" /></dd>
                    <dd class="error"><?=$this->session->flashdata('error_input')?></dd>
                </dl>
                <dl class="one"><dt>Category</dt><dd id="position">
                    <select id="category">
                        <option value="0">All categories</option>
                        <?php foreach($main as $maincat) { ?>
                        <option value="<?=$maincat['id']?>"><?=$maincat['title']?></option>
                        <?php $sub = $this->Category_model->get($maincat['id']);
                            foreach($sub as $subcat) { ?>
                            <option value="<?=$subcat['id']?>"><?=$maincat['title']?> &raquo; <?=$subcat['title']?></option>
                            <?php } ?>                        
                        <?php } ?>
                    </select>
                </dd><dd><input type="button" class="button rounded" value="Search" onclick="searchproduct()" /></dd></dl>
                <dl></dl>
            </div>
            <hr />    
            <div id="addfeature">
    
            </div>
        </div>
        
